//
//  ViewController.m
//  UI-03 Homework 手势 响应者链
//
//  Created by 冀永金 on 16/7/18.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "MyLabel.h"
#import "ImageOfButton.h"
#import "CustomView.h"
@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
     [super viewDidLoad];
//    1.通过UILabel封装实现只显示文字的Button
    
    //[self createLabelOfButton];
//    2.通过UIImageView封装实现只显示图片的Button
    
   // [self createImageButton];
   
    
//    以上两种方式, 要考虑到通用性。 封装时, 记得使用iOS9新特性
//   3。 使用自己封装的控件, 加入到前两天编写的登陆页中
    [self config];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)createLabelOfButton {
    MyLabel *labelOfbUtton = [[MyLabel alloc]initWithFrame:CGRectMake(0, 0, 100, 50) text:@"点击" target:self action:@selector(click)  backColor:[UIColor redColor] alpha:1];
    [self.view addSubview:labelOfbUtton];
    
}
- (void)createImageButton {
    ImageOfButton *button = [ImageOfButton imageWithFrame:CGRectMake(100, 100, 100, 80) image:[UIImage imageNamed:@"123_1.jpg"] target:self action:@selector(touches)];
    button.userInteractionEnabled = YES;
   
   // button.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:button];
}
- (void)click {
    NSLog(@"点击了图片的button");
}
- (void)touches {
    NSLog(@"点击了label的button");
}
- (void)config {
    // 设置背景图片
    UIImageView *backGroundImage = [[UIImageView alloc]initWithFrame:self.view.frame];
    backGroundImage.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:backGroundImage];
    backGroundImage.alpha = .7;
    UIImageView *imageOfLogo = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 140)];
    [self.view addSubview:imageOfLogo];
    imageOfLogo.image = [UIImage imageNamed:@"logo_lagou"];
    imageOfLogo.center = CGPointMake(self.view.frame.size.width / 2, 200);
    //封装的Image And TextField
    CustomView *viewOfUser = [[CustomView alloc]initWithFrame:CGRectMake(20, 300, self.view.frame.size.width - 40,55) leftImage:[UIImage imageNamed:@"1.png"] placeHolder:@"请输入已验证的手机号或邮箱"];
    [self.view addSubview:viewOfUser];
    CustomView *viewOfPassword = [[CustomView alloc]initWithFrame:CGRectMake(20, 360, self.view.frame.size.width - 40,55) leftImage:[UIImage imageNamed:@"2.png"] placeHolder:@"请输入密码"];
    [self.view addSubview:viewOfPassword];
    MyLabel *button = [MyLabel labelWithFrame:CGRectMake(300, 415, 100, 50) text:@"忘记密码" target:self action:nil backColor:nil alpha:1.00];
    button.textColor = [UIColor whiteColor];
    [self.view addSubview:button];
    MyLabel *buttonOfLogin = [MyLabel labelWithFrame:CGRectMake(20, 485, self.view.frame.size.width - 40, 55) text:@"登录" target:self action:@selector(handleNext:) backColor:[UIColor colorWithRed:0.10 green:0.70 blue:0.54 alpha:1.00] alpha:1.0];
    buttonOfLogin.textColor = [UIColor colorWithRed:0.26 green:0.78 blue:0.66 alpha:1.00];
    buttonOfLogin.font = [UIFont systemFontOfSize:22];
    buttonOfLogin.textAlignment = 1;
    [self.view addSubview:buttonOfLogin];
    MyLabel *buttonOfZhuce = [MyLabel labelWithFrame:CGRectMake(20, 550, self.view.frame.size.width - 40, 55) text:@"注册拉勾" target:self action:@selector(handle:) backColor:[UIColor colorWithRed:0.23 green:0.27 blue:0.22 alpha:1.00] alpha:1.0];
    buttonOfZhuce.font = [UIFont systemFontOfSize:22];
    buttonOfZhuce.textColor = [UIColor colorWithRed:0.09 green:0.66 blue:0.51 alpha:1.00];
    buttonOfZhuce.layer.borderColor = [UIColor colorWithRed:0.24 green:0.61 blue:0.48 alpha:1.00].CGColor;
    buttonOfZhuce.alpha = .7;
    buttonOfZhuce.textAlignment = 1;
    [buttonOfZhuce.layer setBorderWidth:2];
    [buttonOfZhuce.layer setCornerRadius:10];
    [self.view addSubview:buttonOfZhuce];
}
- (void)handleNext:(MyLabel *)button {
    NSLog(@"next");
}
- (void)handle:(MyLabel *)button {
    NSLog(@"注册");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
